<?php
	//Xay dung tim kiem
	$ssFilter 		= $this->arrParam['ssFilter'];
	$page = '';
	if(isset($this->arrParam['page'])){
		$page = '/page/' . $this->arrParam['page'];
	}
	$action_link 	= $this->baseUrl($this->currentController . '/filter/type/order');
	$lblName 		= $this->cmsLinkSort('Tiêu đề','kh.name',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblSoluongnguoitoida 	= $this->cmsLinkSort('Học viên tối đa','kh.soluongnguoitoida',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblPrice 		= $this->cmsLinkSort('Học phí','kh.price',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblID 			= $this->cmsLinkSort('ID','kh.id',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblStatus 		= $this->cmsLinkSort('Status','kh.status',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblOrder 		= $this->cmsLinkSort('Order','kh.order',$ssFilter,$this->imgUrl . '/admin',$action_link);
	
	$keywords 		= $this->formText('keywords',$ssFilter['keywords'],array('class'=>'txtshort txtsearch'));
	
	$linkSearch 	= $this->baseUrl($this->currentController . '/filter/type/search/key/1');
	$btnSearch 		= $this->formButton('search-now','Tìm',array('class' => 'btnsearch', 'onclick'=>"OnSubmitForm('" .$linkSearch . "')"));
	
	$linkResetSearch = $this->baseUrl($this->currentController . '/filter/type/search/key/0');
	$btnResetSearch = $this->formButton('clear-keywords','Xóa',array('class' => 'btnsearch', 'onclick'=>"OnSubmitForm('" .$linkResetSearch ."')"));
	
	$strSearch = $keywords . ' ' . $btnSearch . ' ' . $btnResetSearch;

	$strSearchRight = '';
?>
<div class="app"></div>
<script type="text/javascript">
	//$(document).ready(function(){
	//	var intervalId = 0;
	//	intervalId = setInterval(function(){
	//		$('.app').append('aaaa<br>');
	//	}, 1000);
		//clearInterval(intervalId);
	//});
</script>
<div class="left_content">
	<?php echo $this->render($this->arrParam['controller'] . '/toolbar/left.php');?>
</div>

<div class="right_content">
	<div class="appContent">
		<form action="" method="post" name="appForm">
			<?php echo $this->render($this->arrParam['controller'] . '/toolbar/index.php');?>
			<?php
			if($this->arrParam['save'] == 'ok'){
				echo '<div class="thongbaoThanhCong goc5">Xử lý dữ liệu thành công</div>';
			} 
			?>
			<div class="formList goc5">
				<div class="appTop goct5">
					<div class="block_filter">
						<div class="fl">
							<div class="listSearch">
								<?php echo $strSearch; ?>
								<div class="clr"></div>			
							</div>
						</div>
						<div class="fr">
							<div class="listSelect">
								<?php echo $strSearchRight;?>
								<div class="clr"></div>
							</div>
						</div>
						<div class="clr"></div>
					</div>
				</div>
				<div class="appBody">
					<table class="tblList">
						<tr>
							<th width="20">#</th>
							<th width="20"><input type="checkbox" name="checkbox" id="checkbox" onclick="checkedAll()"></th>
							<th><?php echo $lblName;?></th>
							<th width="100"><?php echo $lblSoluongnguoitoida;?></th>
							<th width="100"><?php echo $lblPrice;?> <span class="note">(VNĐ)</span></th>
							<th width="50"><?php echo $lblStatus;?></th>
							<th width="50"><?php echo $lblOrder;?></th>
							<th width="70">Control</th>
							<th width="50"><?php echo $lblID;?></th>
						</tr>
						<?php
						foreach ($this->Items as $key => $val){ 
							$id 			= $val['id'];
							$name 			= $val['name'];
							$soluongnguoitoida 	= $val['soluongnguoitoida'];
							$order 			= $this->formText('order[' . $val['id'] . ']', $val['order'], array('style'=>'width: 30px; text-align: center;'));
							$status 		= $val['status'];
							$price	 		= $val['price'];
							if($status == 1){
								$linkStatus = $this->baseUrl($this->currentController . '/status/type/0/id/' . $id . $page);
								$status = $this->cmsIconButton('Kích vào để tắt', $this->imgUrl . '/admin/tick.png', $linkStatus);
							}else{
								$linkStatus = $this->baseUrl($this->currentController . '/status/type/1/id/' . $id . $page);
								$status = $this->cmsIconButton('Kích vào để bật', $this->imgUrl . '/admin/publish_x.png', $linkStatus);
							}
								
							$linkInfo		= $this->baseUrl($this->currentController . '/info/id/' . $id . $page);
							$btnInfo		= $this->cmsIconButton('Xem thông tin', $this->imgUrl . '/admin/icon_info.png', $linkInfo);
								
							$linkEdit		= $this->baseUrl($this->currentController . '/edit/id/' . $id . $page);
							$btnEdit		= $this->cmsIconButton('Sửa', $this->imgUrl . '/admin/icon_edit.png', $linkEdit);
								
							$linkDelete		= $this->baseUrl($this->currentController . '/delete/id/' . $id . $page);
							$btnDelete		= $this->cmsIconButton('Xóa', $this->imgUrl . '/admin/publish_r.png', $linkDelete);
								
							$strIconButton 	= $btnInfo . $btnEdit . $btnDelete;

							$name 	= '<b><a href="' . $linkEdit . '">' . $name . '</a></b>';
								
							$cid 			= $this->formCheckbox('cid[]',$val['id']);
							$classRow = 'row1';
							if($key % 2 == 0)
								$classRow = '';
						?>
						<tr class="<?php echo $classRow;?>">
							<td align="center"><?php echo $key + 1;?></td>
							<td align="center"><?php echo $cid;?></td>
							<td align="left"><?php echo $name;?></td>
							<td align="center"><?php echo $soluongnguoitoida;?></td>
							<td align="right"><span class="auto_numberic red"><?php echo $price;?></span></td>
							<td align="center" id="tdStatus<?php echo $id;?>"><?php echo $status;?></td>
							<td align="center"><?php echo $order;?></td>
							<td align="center"><?php echo $strIconButton;?></td>
							<td align="center"><?php echo $id;?></td>
						</tr>
						<?php
						} 
						?>
					</table>
				</div>
				<div class="appBottom">
					<?php
						$currentUrl = $this->baseUrl($this->currentController . '/index');
						echo $this->paginationControl($this->paginator,'Sliding','pagination.phtml',array('currentUrl'=>$currentUrl)); 
					?>
				</div>
			</div>
		</form>
	</div>
</div>
<div class="clr"></div>	
